import React from "react" 
import PropTypes from 'prop-types'
function List({list=[]}){
    return (
        <div>
            {list.map(el=><div key={el.id}>{el.name}</div>)}
        </div>
    )
}
class ListC extends React.Component{
    static detaultProps={
        list:[]
    }
    render(){
        return (
            <div>
                {this.props.list.map(el=><div key={el.id}>{el.name}</div>)}
            </div>
        )
    }
}
List.propTypes={
    list:PropTypes.array.isRequired, 

}
export class Test12 extends React.Component {
    state = {
        list:[
            {
                id:1,
                name:'wgy'
            },
            {
                id:2,
                name:'cxx'
            },
            {
                id:3,
                name:'cz'
            },
        ]
    } 
    render() {
        return (
            <div>
                <h1>12.props校验</h1>
                <List list={this.state.list}/>
                <ListC list={this.state.list}/>
            </div> 
        )
    }
}